if orders and not orders.GetActivatedStop then


function orders:GetActivatedStop(limit)
	if type(limit) == "table" then
		return self:GetActivatedStops(limit.sec_code, "order_num",
				function(o)
					return	o.co_order_num == limit.order_num
				end
			)[1]
	end
end


function orders:GetActivatedStops(sec_code, sort_field, filter)
	return self:GetAllStops(sec_code, sort_field,
			function(o)
				return	(o.stop_order_type == 7				-- activated stop
						or o.stop_order_type == 10)			-- activated t&s
						and bit.band(o.flags, 35) == 33
						and o.co_order_num
						and o.co_order_num > 0
						and (not filter or filter(o))
			end
		)
end


function orders:IsActivatedStop(transaction)
	if type(transaction) == "table" then
		return self:IsNewStop(transaction)
				and transaction.BASE_ORDER_KEY
				and (transaction.STOP_ORDER_KIND == "ACTIVATED_BY_ORDER_SIMPLE_STOP_ORDER"
					or transaction.STOP_ORDER_KIND == "ACTIVATED_BY_ORDER_TAKE_PROFIT_AND_STOP_LIMIT_ORDER"
			)
	end
end

--[[
function orders:ReplaceActivatedStopOrder(order)
	if self:IsOrder(order)
		and not self.stop_replaced[order.order_num]
		and bit.band(order.flags, 35) == 1		-- active
		and (order.stop_order_type == 10		-- activated t&s
			or order.stop_order_type == 7		-- activated stop
		)
	then
		self.stop_replaced[order.order_num] = lib:tickseconds()
		
		local transaction = self:KillStopTransaction(order)
	
		self.log("ReplaceActivatedStopOrder", order)
		
		if order.stop_order_type == 10 then
			transaction.ex__.condition_price = transaction.ex__.condition_price2
		end
		local next_transaction =	self:StopTransaction(transaction)
		--local next_transaction =	order.stop_order_type == 10 and self:TakeStopTransaction(transaction)
									--or order.stop_order_type == 7 and self:StopTransaction(transaction)
			
		local limit
		local limit_transaction
		
		if order.stop_order_type == 10		-- activated t&s
		then
			local t = "new" .. lib:FormatSysdate()
			self:SaveTakeLimit(t, t)
			next_transaction.ex__.take_limit = t
			limit_transaction = self:TakeLimitTransaction(transaction)
			limit_transaction.ex__.take_limit = t
		end
		
		--if not
		return self:sendTransaction(transaction, next_transaction, limit_transaction)
		--then
		--	processor:log("ReplaceActivatedStopOrder error", order)
		----	return
		----elseif order.stop_order_type == 10 then
		----	return self:SendTakeStop(transaction)
		----elseif order.stop_order_type == 7 then
		---- 	return self:SendStop(transaction)
		--end
	end
end
--]]

function orders:ReplaceActivatedStopOrder(order)
	if self:IsOrder(order)
		and not self.stop_replaced[order.order_num]
		and bit.band(order.flags, 35) == 1		-- active
		and (order.stop_order_type == 10		-- activated t&s
			or order.stop_order_type == 7		-- activated stop
		)
	then
		self.stop_replaced[order.order_num] = lib:tickseconds()
		
		local transaction = self:KillStopTransaction(order)
	
		self.log("ReplaceActivatedStopOrder", order)
		
		self:SendTakeStop(transaction, transaction)
	end
end


end -- of file
